package yuanzhui;
public class tuzi extends Thread {
	   int waterAmount;       
	   public void setWater(int w) {
	      waterAmount = w;
	   }
	   public void run() {     
	      while(true) {
	         String name=Thread.currentThread().getName();
	         if(name.equals("兔子")) { 
	              System.out.println(name+"跑了10米") ; 
	              waterAmount=waterAmount-10;  
	              System.out.println("兔子休息10s") ;
	         }
	       
	         System.out.println(" 兔子剩 "+waterAmount);
	         try{  Thread.sleep(10000);  
	         }
	         catch(InterruptedException e){}  
	         if(waterAmount<=0) {
	        	 System.out.println("兔子到达终点") ;
	                 return;    
	         }  
	     }
	   }
}

